<?php
function nvr_styles() {
	if (!is_admin()) {
		
		wp_register_style('reset-css', THE_CSSURI . 'reset.css', '', '', 'screen, all');
		wp_enqueue_style('reset-css');
		
		wp_register_style('normalize-css', THE_CSSURI . 'normalize.css', 'reset-css', '', 'screen, all');
		wp_enqueue_style('normalize-css');
		
		if( nvr_register_font( THE_SHORTNAME . '_heading_font') ){
			wp_enqueue_style( THE_SHORTNAME . '_heading_font');
		}
		
		if( nvr_register_font( THE_SHORTNAME . '_menunav_font') ){
			wp_enqueue_style( THE_SHORTNAME . '_menunav_font');
		}
		
		wp_register_style('skeleton-css', THE_CSSURI . '1140.css', 'normalize-css', '', 'screen, all');
		wp_enqueue_style('skeleton-css');
		
		wp_register_style('font-awesome-css', THE_CSSURI . 'font-awesome.min.css', 'skeleton-css', '', 'screen, all');
		wp_enqueue_style('font-awesome-css');
		
		wp_register_style('main-css', THE_CSSURI . 'main.css', 'skeleton-css', '', 'screen, all');
		wp_enqueue_style('main-css');
		
		wp_register_style('prettyPhoto-css', THE_CSSURI . 'prettyPhoto.css', '', '', 'screen, all');
		wp_enqueue_style('prettyPhoto-css');
		
		wp_register_style('perfectscrollbar-css', THE_CSSURI . 'perfect-scrollbar.min.css', '', '', 'screen, all');
		wp_enqueue_style('perfectscrollbar-css');
		
		wp_register_style('flexslider-css', THE_CSSURI .'flexslider.css', '', '', 'screen, all');
		wp_enqueue_style('flexslider-css');
		
		wp_register_style('layout-css', THE_CSSURI . 'layout.css', '', '', 'screen, all');
		wp_enqueue_style('layout-css');
		
		wp_register_style('color-css', THE_CSSURI . 'color.css', '', '', 'screen, all');
		wp_enqueue_style('color-css');
		
		wp_register_style('stylecustom', THE_STYLEURI . 'style-custom.css', '', '', 'screen, all');
		wp_enqueue_style('stylecustom');
		
		$custom_css = nvr_print_stylesheet();
		wp_add_inline_style( 'stylecustom', $custom_css );
		
		wp_register_style('switcher-css', THE_CSSURI . 'style-switcher.css', '', '', 'screen, all');
		if( nvr_get_option( THE_SHORTNAME . '_enable_switcher')){
			wp_enqueue_style('switcher-css');
		}
		
		wp_register_style('noscript-css', THE_CSSURI .'noscript.css', '', '', 'screen, all');
		wp_enqueue_style('noscript-css');
		
	}
}
add_action('wp_enqueue_scripts', 'nvr_styles');

// get style
if(!function_exists("nvr_print_stylesheet")){
	function nvr_print_stylesheet(){
		
		$shortname = THE_SHORTNAME;
		
		/* Get Theme Color Options */
		$opt_colorTheme		= nvr_get_option($shortname. '_color_theme');    
		
		$textcolorcss  = '';
		if($opt_colorTheme!=''){
			$textcolorcss .= 'a:hover, a.colortext:hover, .colortext a:hover, .colortext{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.white:hover, .black:hover, .grey:hover{color:'.$opt_colorTheme.' !important;}';
			$textcolorcss .= '.button, a.more-link, .button:visited, #maincontent input[type="submit"], #maincontent input[type="reset"], button{ border-color:'.$opt_colorTheme.'; color:'.$opt_colorTheme.'; }';
			$textcolorcss .= '.button:hover, a.more-link:hover, #maincontent input[type="submit"]:hover, #maincontent input[type="reset"]:hover, button:hover{ background:'.$opt_colorTheme.'; border-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.button.color2:hover{background:#fff; color:'.$opt_colorTheme.';}';
			$textcolorcss .= '#headertext #lang_sel .lang_sel_sel{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.secondarymenu  a:hover, .secondarymenu .current_page_item > a, .secondarymenu .current_page_item > a:hover, .secondarymenu .current_page_parent > a, .secondarymenu .current_page_parent > a:hover, .secondarymenu .current-menu-parent > a, .secondarymenu .current-menu-parent > a:hover,
			.secondarymenu .current-menu-item > a, .secondarymenu .current-menu-item > a:hover{background-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.topnav li a:hover, .topnav .current_page_item > a, .topnav  .current_page_item > a:hover, .topnav .current_page_parent > a, .topnav .current_page_parent > a:hover, .topnav .current-menu-parent > a, .topnav .current-menu-parent > a:hover, .topnav .current-menu-item > a, .topnav .current-menu-item > a:hover{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.topnav li li a:hover, .topnav li .current_page_item > a, .topnav li .current_page_item > a:hover, .topnav li .current_page_parent > a, .topnav li .current_page_parent > a:hover, .topnav li .current-menu-parent > a, .topnav li .current-menu-parent > a:hover, .topnav li .current-menu-item > a, .topnav li .current-menu-item > a:hover{color:'.$opt_colorTheme.' !important;}';
			$textcolorcss .= '#subbody .flex-control-nav li a:hover, #subbody .flex-control-nav li a.flex-active{background: '.$opt_colorTheme.';}';
			$textcolorcss .= '#outerbeforecontent{background-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.highlight2{background:'.$opt_colorTheme.';}';
			$textcolorcss .= '.icn-container{border-color:'.$opt_colorTheme.';color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.icn-container.type2{border-color:'.$opt_colorTheme.';background-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.icn-container.type3{color:'.$opt_colorTheme.';}';
			$textcolorcss .= 'html ul.tabs li.active, html ul.tabs li.active a:hover, ul.tabs li a:hover{background: '.$opt_colorTheme.';}';
			$textcolorcss .= '.testiinfo{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.nvr-pf-img div.rollover, div.frameimg div.rollover{background-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.nvr-pf-box:hover .nvr-pf-text .nvr-pf-title a{color:'.$opt_colorTheme.' !important;}';
			$textcolorcss .= '.nvr-pf-text .nvr-pf-cat a:hover{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '#filters li:hover, #filters li.selected{background-color:'.$opt_colorTheme.';border-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.rp-shortcode h3 a:hover{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.archives_list li a:hover{color:'.$opt_colorTheme.';}';
			$textcolorcss .= 'div.meter div{background-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.flexslider-carousel h3 a:hover{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.nvr-trotating .flex-control-paging li a.flex-active {background: '.$opt_colorTheme.';}';
			$textcolorcss .= '.nvr-heading.white .hborder{background-color:'.$opt_colorTheme.' !important;}';
			$textcolorcss .= '.peopleinfo{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.nvr-people .peoplesocial a{background-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '#sidebar li li a:hover, #sidebar li li a.active{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.posttitle a:hover{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.entry-utility2 a:hover{color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.entry-utility a.more-link.btn{color:'.$opt_colorTheme.';}';
			$textcolorcss .= 'article.format-quote .entry-content{background-color:'.$opt_colorTheme.';}';
			$textcolorcss .= 'article.format-link .entry-content{background-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.nav-previous a:hover, .nav-next a:hover{color:'.$opt_colorTheme.';	border-color:'.$opt_colorTheme.' !important;}';
			$textcolorcss .= '.postscontainer.mason.timeline .startline{background-color:'.$opt_colorTheme.'; border:2px solid '.$opt_colorTheme.';}';
			$textcolorcss .= '#loadmore-paging .loadmorebutton a, #loadmore-paging .loadmorebutton span{background-color:'.$opt_colorTheme.'; border:1px solid '.$opt_colorTheme.';}';
			$textcolorcss .= '#loadmore-paging .loadmorebutton a:hover{background-color:'.$opt_colorTheme.'; border:1px solid '.$opt_colorTheme.';}';
			$textcolorcss .= '.commentlist .comment-body .reply{background-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '.wp-pagenavi a:hover{background-color:'.$opt_colorTheme.';border-color:'.$opt_colorTheme.' !important;}';
			$textcolorcss .= '.wp-pagenavi span.current{background:'.$opt_colorTheme.';border-color:'.$opt_colorTheme.' !important;}';
			$textcolorcss .= '#megaMenu li.menu-item.ss-nav-menu-mega ul.sub-menu.sub-menu-1, #megaMenu li.menu-item.ss-nav-menu-reg ul.sub-menu.sub-menu-1{border-color:'.$opt_colorTheme.';}';
			$textcolorcss .= '#megaMenu.megaMenu-withjs ul li.menu-item.ss-nav-menu-reg ul.sub-menu > li.menu-item > ul.sub-menu{ border-color:'.$opt_colorTheme.';}';
		}
		
		/* Get Header Background Option */
		$opt_bgHeader 		= nvr_get_option($shortname. '_header_background');    
		$cf_bgHeader 		= '';
		$cf_bgRepeat 		= "no-repeat";
		$cf_bgPos	 		= "center";
		$cf_bgAttch	 		= "";
		$cf_bgColor	 		= "transparent";
		
		if( $opt_bgHeader){
			if($opt_bgHeader["background-image"]!=""){
				$cf_bgHeader 	= $opt_bgHeader["background-image"];
				$cf_bgRepeat 		= $opt_bgHeader["background-repeat"];
				$cf_bgPos	 		= $opt_bgHeader["background-position"];
				$cf_bgAttch	 		= $opt_bgHeader["background-attachment"];
			}
			$cf_bgColor	 		= ($opt_bgHeader["background-color"]!="")? $opt_bgHeader["background-color"] : "";
		}
		
		/* Get Body Background Option */
		$optBodyBGColor = '';
		$optBodyBGImage = '';
		$optBodyBGPosition = 'center';
		$optBodyBGStyle = 'repeat';
		$optBodyBGattachment = '';
		$optBodyBGSize = '';
		
		$optBodyBG = nvr_get_option( $shortname . '_body_background');
		if($optBodyBG){
			$optBodyBGColor = $optBodyBG['background-color'];
			$optBodyBGImage = $optBodyBG['background-image'];
			$optBodyBGPosition = $optBodyBG['background-position'];
			$optBodyBGStyle = $optBodyBG['background-repeat'];
			$optBodyBGattachment = $optBodyBG['background-attachment'];
			$optBodyBGSize = $optBodyBG['background-size'];
		}
		/* Get After Content Background Option */
		$opt_bgAfterC = nvr_get_option( $shortname . '_aftercontent_background');
		$cf_bgAfterC 		= "";
		$cf_bgRepeatAfterC	= "repeat";
		$cf_bgPosAfterC		= "center";
		$cf_bgColorAfterC	= "transparent";

		if( $opt_bgAfterC ){
			if($opt_bgAfterC["image"]!=""){
				$cf_bgAfterC 	= $opt_bgAfterC["background-image"];
			}
			$cf_bgRepeatAfterC	= $opt_bgAfterC["background-repeat"];
			$cf_bgPosAfterC		= $opt_bgAfterC["background-position"];
			$cf_bgAttchAfterC	= $opt_bgAfterC["background-attachment"];
			$cf_bgColorAfterC	= ($opt_bgAfterC["background-color"]!="")? $opt_bgAfterC["background-color"] : "#333333";
		}
		
		/* Get Footer Background Option */
		$opt_bgFooter 		= nvr_get_option($shortname. '_footer_background');
		$cf_bgFooter 		= "";
		$cf_bgRepeatFooter	= "repeat";
		$cf_bgPosFooter		= "center";
		$cf_bgColorFooter	= "transparent";
		
		if( $opt_bgFooter ){
			if($opt_bgFooter["image"]!=""){
				$cf_bgFooter 	= $opt_bgFooter["background-image"];
			}
			$cf_bgRepeatFooter	= $opt_bgFooter["background-repeat"];
			$cf_bgPosFooter		= $opt_bgFooter["background-position"];
			$cf_bgAttchFooter	= $opt_bgFooter["background-attachment"];
			$cf_bgColorFooter	= ($opt_bgFooter["background-color"]!="")? $opt_bgFooter["background-color"] : "#2d2d2d";
		}
		
		/* Get Google Font Option */
		$optGeneralTextFont = nvr_get_option( THE_SHORTNAME . '_general_font');
		
		$optBigTextFont = nvr_get_option( THE_SHORTNAME . '_bigtext_font');

		$optHeadingFont = nvr_get_option( THE_SHORTNAME . '_heading_font');
		if($optHeadingFont!="0"){
			$HeadingFont = explode(":",$optHeadingFont);
			$HeadingOutput = "'". $HeadingFont[0] . "',";
		}
		
		$optMenuFont = nvr_get_option( THE_SHORTNAME . '_menunav_font');
		if($optMenuFont!="0"){
			$MenuFont = explode(":",$optMenuFont);
			$MenuOutput = "'". $MenuFont[0] . "',";
		}
		
		$txtContainerWidth = intval( nvr_get_option( THE_SHORTNAME . '_container_width') );

		//get background from metabox
		$pid = nvr_get_postid();
		$custom = nvr_get_customdata($pid);
		$cf_bgHeader 		= (isset($custom["bg_header"][0]))? $custom["bg_header"][0] : $cf_bgHeader;
		$cf_bgRepeat 		= (isset($custom["bg_repeat"][0]) && trim($custom["bg_repeat"][0])!="")? $custom["bg_repeat"][0] : $cf_bgRepeat;
		$cf_bgPos	 		= (isset($custom["bg_pos"][0]) && trim($custom["bg_pos"][0])!="")? $custom["bg_pos"][0] : $cf_bgPos;
		$cf_bgAttch	 		= (isset($custom["bg_attch"][0]) && trim($custom["bg_attch"][0])!="")? $custom["bg_attch"][0] : $cf_bgAttch;
		$cf_bgColor	 		= (isset($custom["bg_color"][0]) && trim($custom["bg_color"][0])!="")? $custom["bg_color"][0] : $cf_bgColor;
		
		$cf_pagebgimg = (isset($custom["page-bgimg"][0]))? $custom["page-bgimg"][0] : "";
		$cf_pagebgposition = (isset($custom["page-bgposition"][0]))? $custom["page-bgposition"][0] : "";
		$cf_pagebgstyle = (isset($custom["page-bgstyle"][0]))? $custom["page-bgstyle"][0] : "";
		$cf_pagebgattch = (isset($custom["page-bgattch"][0]))? $custom["page-bgattch"][0] : "";
		$cf_pagebgcolor = (isset($custom["page-bgcolor"][0]))? $custom["page-bgcolor"][0] : "";
		
		$cf_bgMainC  		= (isset($custom["bg_maincontent"][0]))? $custom["bg_maincontent"][0] : '';
		$cf_bgRepeatMainC 	= (isset($custom["bg_repeat_maincontent"][0]) && trim($custom["bg_repeat_maincontent"][0])!="")? $custom["bg_repeat_maincontent"][0] : 'repeat';
		$cf_bgPosMainC 	= (isset($custom["bg_pos_maincontent"][0]) && trim($custom["bg_pos_maincontent"][0])!="")? $custom["bg_pos_maincontent"][0] : 'center';
		$cf_bgColorMainC 	= (isset($custom["bg_color_maincontent"][0]) && trim($custom["bg_color_maincontent"][0])!="")? $custom["bg_color_maincontent"][0] : 'transparent';
		
		$cf_bgAfterC  		= (isset($custom["bg_aftercontent"][0]))? $custom["bg_aftercontent"][0] : $cf_bgAfterC;
		$cf_bgRepeatAfterC 	= (isset($custom["bg_repeat_aftercontent"][0]) && trim($custom["bg_repeat_aftercontent"][0])!="")? $custom["bg_repeat_aftercontent"][0] : $cf_bgRepeatAfterC;
		$cf_bgPosAfterC 	= (isset($custom["bg_pos_aftercontent"][0]) && trim($custom["bg_pos_aftercontent"][0])!="")? $custom["bg_pos_aftercontent"][0] : $cf_bgPosAfterC;
		$cf_bgColorAfterC 	= (isset($custom["bg_color_aftercontent"][0]) && trim($custom["bg_color_aftercontent"][0])!="")? $custom["bg_color_aftercontent"][0] : $cf_bgColorAfterC;
		
		$cf_bgFooter 		= (isset($custom["bg_footer"][0]))? $custom["bg_footer"][0] : $cf_bgFooter;
		$cf_bgRepeatFooter	= (isset($custom["bg_repeat_footer"][0]) && trim($custom["bg_repeat_footer"][0])!="")? $custom["bg_repeat_footer"][0] : $cf_bgRepeatFooter;
		$cf_bgPosFooter		= (isset($custom["bg_pos_footer"][0]) && trim($custom["bg_pos_footer"][0])!="")? $custom["bg_pos_footer"][0] : $cf_bgPosFooter	;
		$cf_bgColorFooter	= (isset($custom["bg_color_footer"][0]) && trim($custom["bg_color_footer"][0])!="")? $custom["bg_color_footer"][0] : $cf_bgColorFooter;
		
		$print_custom_css = '';
		
		$print_custom_css .= $textcolorcss;
		
		$bodycss = '';
		$generalTextOutput = '';
		if($optGeneralTextFont){
			foreach($optGeneralTextFont as $generalTextFont => $generalTextFontVal){
				if($generalTextFont!='google' && $generalTextFont!='subsets' && $generalTextFont!='font-options' && $generalTextFontVal!=''){
					if($generalTextFont=='font-family'){$generalTextFontVal = $generalTextOutput = "'".$generalTextFontVal."'";}
					$bodycss .= $generalTextFont. ": ".$generalTextFontVal.";";
				}
			}
		}
		
		if($cf_pagebgimg!=""){
			$bodycss .= 'background-image:url('. $cf_pagebgimg .');';
			$bodycss .= 'background-repeat:'. $cf_pagebgstyle  .';';
			$bodycss .= 'background-repeat:'. $cf_pagebgattch  .';';
			$bodycss .= 'background-position:'. $cf_pagebgposition .';';
			$bodycss .= 'background-color:'. $cf_pagebgcolor .';';
		
		}else{
			if($optBodyBGImage!="" || $optBodyBGColor!=""){
				$bodycss .= 'background-color:'. $optBodyBGColor .';';
				$bodycss .= 'background-image:url('. $optBodyBGImage .');';
				$bodycss .= 'background-repeat:'. $optBodyBGStyle .';';
				$bodycss .= 'background-position:'. $optBodyBGPosition .';';
				$bodycss .= 'background-attachment:'. $optBodyBGattachment .';';
			}
		}
		$print_custom_css .='body{'.$bodycss.'}';
		
		$outertopcss = '';
		if($cf_bgHeader){
			$outertopcss .='background-image:url('. $cf_bgHeader .');';
		}
		$outertopcss .='background-repeat:'. $cf_bgRepeat .'; background-position:'. $cf_bgPos .'; background-color:'. $cf_bgColor .';';
		$print_custom_css .='#outertop{'.$outertopcss.'}';

		if(strlen($optMenuFont)>2){
			$print_custom_css .='.topnav li a, .topnav li a:visited{font-family:'. $MenuOutput .' sans-serif !important;}';
		}elseif($generalTextOutput!=''){
			$print_custom_css .='.topnav li a, .topnav li a:visited{font-family:'. $generalTextOutput .' sans-serif !important;}';
		}
		
		if($optHeadingFont!="0"){
			$print_custom_css .='h1, h2, h3, h4, h5, h6{font-family:'. $HeadingOutput .' sans-serif !important;}';
		}
		
		$bigtextcss = '';
		if($optBigTextFont){
			foreach($optBigTextFont as $bigTextFont => $bigTextFontVal){
				if($bigTextFont!='google' && $bigTextFont!='subsets' && $bigTextFont!='font-options' && $bigTextFontVal!=''){
					if($bigTextFont=='font-family'){$bigTextFontVal = "'".$bigTextFontVal."'";}
					$bigtextcss .= $bigTextFont. ": ".$bigTextFontVal.";";
				}
			}
		}
		$print_custom_css .='.bigtext{'. $bigtextcss .'}';

		if($txtContainerWidth>=940 && $txtContainerWidth <=1200){
			$print_custom_css .='#subbody .container{max-width:'. $txtContainerWidth.'px;}';
			$print_custom_css .='.nvrlayout5 #subbody{max-width:'. $txtContainerWidth.'px;}';
		}
		
		$outermain = '';
		if($cf_bgMainC){
			$outermain .='background-image:url('. $cf_bgMainC .');';
		}
		$outermain .='background-repeat:'. $cf_bgRepeatMainC .'; background-position:'. $cf_bgPosMainC .'; background-color:'. $cf_bgColorMainC .';';
		$print_custom_css .= '#outermain{'.$outermain.'}';
		
		
		$outeraftercontent = '';
		if($cf_bgAfterC){
			$outeraftercontent .= 'background-image:url('. $cf_bgAfterC .');';
		}
		$outeraftercontent .= 'background-repeat:'. $cf_bgRepeatAfterC .'; background-position:'. $cf_bgPosAfterC .'; background-color:'. $cf_bgColorAfterC .';';
		$print_custom_css .= '#outeraftercontent{'. $outeraftercontent .'}';
		
		$footerwrapper = '';
		if($cf_bgFooter){
			$footerwrapper .= 'background-image:url('. $cf_bgFooter .');';
		}
		$footerwrapper .= 'background-repeat:'. $cf_bgRepeatFooter .'; background-position:'. $cf_bgPosFooter .'; background-color:'. $cf_bgColorFooter .';';
		$print_custom_css .= '#footerwrapper{'. $footerwrapper .'}';
		
		return $print_custom_css;
		
	}// end function nvr_print_stylesheet
}